#pragma once

struct CChartParam
{
    enum ParamType{ None = -1, V, I, T, E, V_AVG, V_MAX, V_MIN, T_AVG, T_MAX, T_MIN, VARIANCE_V, VARIANCE_T };

    ParamType type;
    int *cellid;
    int cellcnt;

    CChartParam():cellid(0),cellcnt(0)
    {
    }

    CChartParam(const CChartParam &RightSide): cellid(0), cellcnt(0)
    {
        this->type = RightSide.type;
        this->cellcnt = RightSide.cellcnt;
        if (cellcnt > 0)
        {
            cellid = new int[cellcnt];
            memcpy(cellid, RightSide.cellid, cellcnt);
        }
    }

    CChartParam( const ParamType type, int cellid[], const int cellcnt ):cellid(0),cellcnt(0)
    {
        this->type = type;
        if (cellcnt > 0)
        {
            this->cellid = new int[cellcnt];
            memcpy(this->cellid, cellid, cellcnt*sizeof(int));
            this->cellcnt = cellcnt;
        }
    }

    ~CChartParam()
    {
        if ( cellid != NULL )
        {
            delete[] cellid;
        }
    }

    CChartParam& operator =(const CChartParam &RightSide)
    {
        if (this != &RightSide)
        {
            this->type = RightSide.type;
            this->cellcnt = RightSide.cellcnt;
            if (cellid)
            {
                delete[] cellid;
                cellid = NULL;
            }
            if (cellcnt > 0)
            {
                cellid = new int[cellcnt];
                memcpy(cellid, RightSide.cellid, cellcnt*sizeof(int));
            }
        }
        return *this;
    }
};
